#ifndef _WIFI_NETWORK_H
#define _WIFI_NETWORK_H

#include <WiFi.h>
#include <DNSServer.h>
#include <WebServer.h>
#include <ESPmDNS.h>      //用于设备域名 MDNS.begin("esp32")
#include <esp_wifi.h>     //用于esp_wifi_restore() 删除保存的wifi信息

//定义根目录首页网页HTML源代码
#define ROOT_HTML  "<!DOCTYPE html><html><head><title>WIFI Config by lwang</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"></head><style type=\"text/css\">.input{display: block; margin-top: 10px;}.input span{width: 100px; float: left; float: left; height: 36px; line-height: 36px;}.input input{height: 30px;width: 200px;}.btn{width: 120px; height: 35px; background-color: #000000; border:0px; color:#ffffff; margin-top:15px; margin-left:100px;}</style><body><form method=\"POST\" action=\"configwifi\"><label class=\"input\"><span>WiFi SSID</span><input type=\"text\" name=\"ssid\" value=\"\"></label><label class=\"input\"><span>WiFi PASS</span><input type=\"text\"  name=\"pass\"></label><input class=\"btn\" type=\"submit\" name=\"submit\" value=\"Submie\"> <p><span> Nearby wifi:</P></form>"
//定义成功页面HTML源代码
#define SUCCESS_HTML  "<html><body><font size=\"10\">successd,wifi connecting...<br />Please close this page manually.</font></body></html>"

//定义天气类
class Network
{
    public:
        Network(char* ap_ssid, char* host_name);
       
        void initSoftAP();
        void initDNS();
        void wifiConfig();
        void connectToWiFi(int timeOut_s);
        //void handleRoot();
        //void handleConfigWifi();
        
        void initWebServer();
        bool scanWiFi();
        void blinkLED(int led,int n,int t);
        void restoreWiFi();
        int checkConnect(bool reConnect);
        int networkTask(void);
    private:
        char* AP_SSID;      //设置AP热点名称
        //const char* AP_PASS  = "";                      //设置AP热点密码
        char* HOST_NAME;     //设置设备名
};

#endif
